package com.example.user.enumerate;

import com.google.common.collect.ImmutableMap;

/**
 * 操作类型枚举
 */
public enum OperateTypeEnum {
    REGISTER("1"),
    REAL_NAME("2"),
    BIND_BANKCARD("3");

    private String type;

    OperateTypeEnum(String type) {
        this.type = type;
    }

    /**
     * id enum map
     */
    private static final ImmutableMap<String, OperateTypeEnum> INT_ENUM_MAP;

    static {
        final ImmutableMap.Builder<String, OperateTypeEnum> builder = new ImmutableMap.Builder<>();
        for (final OperateTypeEnum value : OperateTypeEnum.values()) {
            builder.put(value.type, value);
        }
        INT_ENUM_MAP = builder.build();
    }

    /**
     * string to enum
     *
     * @param value 待转换枚举值
     * @return GenerateSlipIdTypeEnum
     */
    public static OperateTypeEnum of(final String value) {
        return INT_ENUM_MAP.get(value);
    }
}
